package com.blb.springboot.controller;

import com.blb.springboot.entity.User;
import com.blb.springboot.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/Login")
    public String userLogin(User user, HttpSession session){
        User user1= userService.selectUser(user);
        if (user1!=null){
           session.setAttribute("user",user1);
           return "redirect:/all";
        }else {
            return "login";
        }
    }


    @RequestMapping("/Register")
    public String UserRegister(User user){
        userService.insertUser(user);
        return "login";
    }


}
